package org.forum.service.impl;

import java.io.File;
import java.io.Serializable;
import java.util.Map;

import org.forum.dao.UserDao;
import org.forum.domain.User;
import org.forum.service.UserService;

public class UserServiceImpl implements UserService {
	
	//用户图标存放地址
	private String userIconPersistenceUrl;

	
	public UserDao<User> userDao;

	public void setUserDao(UserDao<User> userDao) {
		this.userDao = userDao;
	}



	@Override
	public boolean verifyPassword(User user) {
		if(userDao.findUserByUsernameAndPassword(user) != null){
			return true;
		}
		return false;
	}



	@Override
	public boolean isAccountAlreadyExist(User user) {
		if(userDao.findUserByUsername(user) != null){
			return true;
		}
		return false;
	}



	@Override
	public Serializable saveUser(User user) {
		return userDao.saveUser(user);
	}
	
	@Override
	public void updateUser(User user) {
		userDao.update(user);
	}



	@Override
	public String getPersistenceUrl(File file) {
		return userIconPersistenceUrl + File.separator + file.getName();
	}



	@Override
	public Map<String, User> getUserInfoByIds(Map<String, String> userIds) {
		return userDao.getUserInfoByIds(userIds);
	}
}
